var $$ = mdui.JQ;

var inst = new mdui.Drawer('#drawer');
document.getElementById('menu-open').addEventListener('click', function () {
    if (inst.getState() == "closed") {
        inst.open();
    } else {
        inst.close();
    }
});


$(document).ready(function () {
    if ($.cookie('dark') === 'true') {
        read_mode();
    }
})

function read_mode() {
    var body = $('#body-content');
    var sidebar_home = $('#sidebar_home');
    var post_nav_bar = $('#post_nav_bar');
    var content_body = $('#content_body');

    if (body.hasClass('mdui-theme-layout-dark')) {
        body.removeClass('mdui-theme-layout-dark')
        sidebar_home.removeClass('a-li');
        post_nav_bar.removeClass('post_nav_bar');
        content_body.removeClass('a-li');
        $('#hightlight').href = '//apps.bdimg.com/libs/highlight.js/9.1.0/styles/atelier-dune-light.min.css';
        mdui.snackbar({
            timeout: 100,
            message: '已关闭夜间模式',
            position: 'right-bottom'
        });
        $.cookie('dark', false);
    } else {
        body.addClass('mdui-theme-layout-dark')
        sidebar_home.addClass('a-li');
        post_nav_bar.addClass('post_nav_bar');
        content_body.addClass('a-li');
        $('#hightlight').href = '//apps.bdimg.com/libs/highlight.js/9.1.0/styles/atelier-dune-dark.min.css';
        mdui.snackbar({
            timeout: 100,
            message: '已启用夜间模式',
            position: 'right-bottom'
        });
        $.cookie('dark', true);
    }
    
}


document.getElementById('menu-mode').addEventListener('click', function () {
    read_mode();
});



